#include "EItem.h"
#ifndef ECOMMANDMANAGER_H 
#define ECOMMANDMANAGER_H 1

#include <iostream>
#include <deque>
#include <map>
#include <stack>
#include <vector>
#include <DefineLibCommon.h>
#include <DefineCommon.h>
#include <ECommand.h>
#include <ECommandHandler.h>
#include <EController.h>

struct ECommandManagerData;
typedef EDelegate(void (EController::*)(const ECommandPtr& )) ECommandDelegate;
class COMMON_DLL ECommandManager
{
public:
    ~ECommandManager();
    static ECommandManager* instance();

    /*called by outer frame, maybe a QTimer or other iterative calling.
     *Other iterative calling, for example travel all EItem, is called in this function
    */
    void processECommand();

    void processECommandUndoOnce();
    void processECommandRedoOnce();

    void pushECommand(ECommandPtr event);

    void registDelegate( ECommandDelegate e);
    void unregistDelegate(EController* controller);

protected:
    //TODO: the plan of command type str formulate should be maked in the future 
    ECommandManagerData* m_data;

private:
    ECommandManager();

    static ECommandManager * m_instance;
};
#endif // !
